home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d882.lha
/
GALer
/
GALer_english
/
Source
/
GALerSrcE.lha
/
Sub.c
< prev
Wrap
C/C++ Source or Header
|
1993-06-08
|
40KB
|
1,552 lines
/****************************************************************/
/* */
/* Sub.c - dieses Modul enthält Unterroutinen für den GALer */
/* */
/* compilieren: cc sub.c */
/* */
/****************************************************************/
#include <exec/types.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <stdio.h>
#include <ctype.h>
#include <functions.h>
#include "GALer.h"
#include "reqbase.h"
#define YES_GADID 1
#define NO_GADID 2
#define GALGAL_GADID 3
#define GALJEDEC_GADID 4
#define JEDECGAL_GADID 5
#define JEDEC_GADID 1
#define FUSE_GADID 2
#define CHIP_GADID 3
#define PIN_GADID 4
#define AUTOSAVE_GADID 5
#define AUTOGAL_GADID 6
#define WEITER_GADID 7
#define ABBRUCH_GADID 8
#define JED_SEC_GADID 3
#define JED_FSCHK_GADID 4
#define JED_FLCHK_GADID 5
extern struct Window *window;
extern struct RastPort *rp;
extern struct MenuItem MenuItem13, MenuItem13b;
extern struct MenuItem MenuItem14, MenuItem14a, MenuItem14b;
extern int GALType, MaxFuseAdr, SigAdr;
extern UBYTE title[];
int ytxt = 160; /*Startpos. für PrintText*/
/*Voreinstellungen*/
struct Configuration Config = { GAL16V8, /*GAL16V8*/
NO, /*kein A-Typ*/
YES, /*Requester für Typ*/
YES, /*auto. A-Typ-Erkennung*/
YES, /*Jedec erzeugen*/
NO, /*kein Fuse-File*/
NO, /*kein Chip-File*/
NO, /*kein Pin-File*/
NO, /*kein Auto-Save*/
YES, /*autom. GALTyp einstellen*/
YES, /*Leertest vor GAL-Prog.*/
YES, /*Verify nach GAL-Prog.*/
YES, /*Leertest vor Copy-GAL*/
YES, /*Verify nach Copy-GAL*/
YES, /*Leertest nach GAL-Löschen*/
NO, /*Sec.Bit der Jedec-Datei*/
YES, /*Fuse-Checksumme der Jedec*/
NO /*File-Checksumme der Jedec*/
};
struct Configuration DummyConfig; /*für LoadConfig*/
UBYTE ErrorLineStr[] = "Error in line ....:";
SHORT BorderVectorsRa[] = { 0,14,82,14,82,0 };
SHORT BorderVectorsRb[] = { 0,14,0,0,82,0 };
struct Border BorderRb = {-1,-1,2,0,JAM1,3,BorderVectorsRb,NULL};
struct Border BorderRa = {-1,-1,1,0,JAM1,3,BorderVectorsRa,&BorderRb};
struct IntuiText ITextN = {2,0,JAM1,14,3,NULL,NULL,NULL};
struct IntuiText ITextY = {2,0,JAM1,16,3,NULL,NULL,NULL};
struct Gadget GadgetN = {NULL,206,53,81,13,NULL,RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&BorderRa,NULL,&ITextN,NULL,NULL,NO_GADID,NULL};
struct Gadget GadgetY = {&GadgetN,26,53,81,13,NULL,RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&BorderRa,NULL,&ITextY,NULL,NULL,YES_GADID,NULL};
struct IntuiText ITextW = {2,0,JAM1,19,15,NULL,NULL,NULL};
SHORT SBorderVectors1a[] = { 0,12,73,12,73,0 };
SHORT SBorderVectors1b[] = { 0,12,0,0,73,0 };
SHORT SBorderVectors2a[] = { 0,14,85,14,85,0 };
SHORT SBorderVectors2b[] = { 0,14,0,0,85,0 };
SHORT SBorderVectors3a[] = { 0,8,14,8,14,0 };
SHORT SBorderVectors3b[] = { 0,8,0,0,14,0 };
struct Border SBorder1b = { -1,-1,2,0,JAM1,3,SBorderVectors1b,NULL };
struct Border SBorder1a = { -1,-1,1,0,JAM1,3,SBorderVectors1a,&SBorder1b };
struct Border SBorder2b = { -1,-1,2,0,JAM1,3,SBorderVectors2b,NULL };
struct Border SBorder2a = { -1,-1,1,0,JAM1,3,SBorderVectors2a,&SBorder2b };
struct Border SBorder3b = { -1,-1,2,0,JAM1,3,SBorderVectors3b,NULL};
struct Border SBorder3a = { -1,-1,1,0,JAM1,3,SBorderVectors3a,&SBorder3b};
struct IntuiText SIText1 = { 2,0,JAM1,9,2,NULL,
(UBYTE *)"Cancel",NULL };
struct IntuiText SIText2 = { 2,0,JAM1,13,2,NULL,
(UBYTE *)" Cont",NULL };
struct IntuiText SIText4 = { 2,0,JAM1,22,0,NULL,
(UBYTE *)"adjust type of GAL",NULL };
struct IntuiText SIText8 = { 2,0,JAM1,22,0,NULL,
(UBYTE *)"Autosave",NULL };
struct IntuiText SIText9 = { 2,0,JAM1,22,0,NULL,
(UBYTE *)"Pin-Diagram",NULL };
struct IntuiText SIText10= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"Chip-Diagram",NULL };
struct IntuiText SIText11= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"Fuse-Matrix",NULL };
struct IntuiText SIText12= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"JEDEC",NULL };
struct IntuiText SIText13= { 2,0,JAM1,15,18,NULL,
(UBYTE *)"save files:", NULL };
struct IntuiText SIText14= { 2,0,JAM1,14,3,NULL,
(UBYTE *)"Cancel",NULL };
struct IntuiText SIText15= { 2,0,JAM1,6,3,NULL,
(UBYTE *)"GAL20V8 A",NULL };
struct IntuiText SIText16= { 2,0,JAM1,14,3,NULL,
(UBYTE *)"GAL20V8",NULL };
struct IntuiText SIText17= { 2,0,JAM1,6,3,NULL,
(UBYTE *)"GAL16V8 A",NULL };
struct IntuiText SIText18= { 2,0,JAM1,14,3,NULL,
(UBYTE *)"GAL16V8",NULL };
struct IntuiText SIText20= { 2,0,JAM1,0,15,NULL,NULL,NULL };
struct IntuiText SIText19= { 2,0,JAM1,8,30,NULL,
(UBYTE *)" Please insert GAL and select type of GAL.",&SIText20 };
struct IntuiText SIText21= { 2,0,JAM1,21,2,NULL,
(UBYTE *)"O.K.",NULL };
struct IntuiText SIText30= { 2,0,JAM1,6,3,NULL,
(UBYTE *)" GAL-GAL",NULL };
struct IntuiText SIText31= { 2,0,JAM1,6,3,NULL,
(UBYTE *)"GAL-JEDEC",NULL };
struct IntuiText SIText32= { 2,0,JAM1,6,3,NULL,
(UBYTE *)"JEDEC-GAL",NULL };
struct IntuiText SIText33= { 2,0,JAM1,19,20,NULL,
(UBYTE *)" Please select kind of comparison.",NULL };
struct IntuiText SIText44= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"with verify",NULL };
struct IntuiText SIText43= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"with blank test",NULL };
struct IntuiText SIText42= { 2,0,JAM1,15,10,NULL,
(UBYTE *)"programming:", NULL };
struct IntuiText SIText41= { 2,0,JAM1,15,45,NULL,
(UBYTE *)"copying", &SIText42 };
struct IntuiText SIText40= { 2,0,JAM1,15,80,NULL,
(UBYTE *)"erasing:", &SIText41 };
struct IntuiText SIText53= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"File-Checksum",NULL };
struct IntuiText SIText52= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"Fuse-Checksum",NULL };
struct IntuiText SIText51= { 2,0,JAM1,22,0,NULL,
(UBYTE *)"Security bit",NULL };
struct IntuiText SITextJR= { 2,0,JAM1,15,10,NULL,
(UBYTE *)"write JEDEC file:",NULL };
struct IntuiText AboutTxt7 = {2,0,JAM1,177,75,NULL,
(UBYTE *)"Germany",NULL };
struct IntuiText AboutTxt6 = {2,0,JAM1,177,65,NULL,
(UBYTE *)"85356 Freising",&AboutTxt7 };
struct IntuiText AboutTxt5 = {2,0,JAM1,177,55,NULL,
(UBYTE *)"Asamstr. 17",&AboutTxt6 };
struct IntuiText AboutTxt4 = {2,0,JAM1,25,45,NULL,
(UBYTE *)"My address: Christian Habermann",&AboutTxt5 };
struct IntuiText AboutTxt3 = {2,0,JAM1,25,30,NULL,
(UBYTE *)"donation of 15 US $ (see manual). Thank you!",&AboutTxt4 };
struct IntuiText AboutTxt2 = {2,0,JAM1,25,20,NULL,
(UBYTE *)"program and / or the hardware, please send me a",&AboutTxt3 };
struct IntuiText AboutTxt1 = {2,0,JAM1,25,10,NULL,
(UBYTE *)"The project 'GALer' is SHAREWARE. If you use this",&AboutTxt2 };
struct IntuiText ATypeTxt = {2,0,JAM1,75,30,NULL,
(UBYTE *)"and select type of GAL." };
struct Gadget SGadget12 = { NULL,179,120,72,11,
NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder1a,NULL,
&SIText1,NULL,NULL,ABBRUCH_GADID,NULL };
struct Gadget SGadget11 = { &SGadget12,18,120,72,11,
NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder1a,NULL,
&SIText2,NULL,NULL,WEITER_GADID,NULL };
struct Gadget SGadget9 = { &SGadget11,18,91,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText4,NULL,NULL,AUTOGAL_GADID,NULL };
struct Gadget SGadget5 = { &SGadget9,62,72,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText8,NULL,NULL,AUTOSAVE_GADID,NULL };
struct Gadget SGadget4 = { &SGadget5,62,59,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText9,NULL,NULL,PIN_GADID,NULL };
struct Gadget SGadget3 = { &SGadget4,62,49,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText10,NULL,NULL,CHIP_GADID,NULL };
struct Gadget SGadget2 = { &SGadget3,62,39,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText11,NULL,NULL,FUSE_GADID,NULL };
struct Gadget SGadget1 = { &SGadget2,62,29,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText12,NULL,NULL,JEDEC_GADID,NULL };
struct Gadget SGadget24 = { NULL,164,77,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText14,NULL,NULL,NO_GADID,NULL };
struct Gadget SGadget23 = { &SGadget24,312,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText15,NULL,NULL,6,NULL };
struct Gadget SGadget22 = { &SGadget23,216,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText16,NULL,NULL,5,NULL };
struct Gadget SGadget21 = { &SGadget22,121,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText17,NULL,NULL,4,NULL };
struct Gadget SGadget20 = { &SGadget21,25,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText18,NULL,NULL,3,NULL };
struct Gadget SGadget33 = { NULL,133,77,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText14,NULL,NULL,NO_GADID,NULL };
struct Gadget SGadget32 = { &SGadget33,240,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText32,NULL,NULL,JEDECGAL_GADID,NULL };
struct Gadget SGadget31 = { &SGadget32,133,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText31,NULL,NULL,GALJEDEC_GADID,NULL };
struct Gadget SGadget30 = { &SGadget31,25,50,84,13,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder2a,NULL,
&SIText30,NULL,NULL,GALGAL_GADID,NULL };
struct Gadget SGadget46 = { NULL,45,90,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText43,NULL,NULL,7,NULL };
struct Gadget SGadget45 = { &SGadget46,45,65,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText44,NULL,NULL,6,NULL };
struct Gadget SGadget44 = { &SGadget45,45,55,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText43,NULL,NULL,5,NULL };
struct Gadget SGadget43 = { &SGadget44,45,30,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText44,NULL,NULL,4,NULL };
struct Gadget SGadget42 = { &SGadget43,45,20,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText43,NULL,NULL,3,NULL };
struct Gadget SGadget40 = { &SGadget42,98,115,72,11,
NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder1a,NULL,
&SIText21,NULL,NULL,YES_GADID,NULL };
struct Gadget SGadget53 = { NULL,25,42,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText53,NULL,NULL,JED_FLCHK_GADID,NULL };
struct Gadget SGadget52 = { &SGadget53,25,32,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText52,NULL,NULL,JED_FSCHK_GADID,NULL };
struct Gadget SGadget51 = { &SGadget52,25,22,13,7,
NULL,
RELVERIFY+TOGGLESELECT,
BOOLGADGET+REQGADGET,
(APTR)&SBorder3a,NULL,
&SIText51,NULL,NULL,JED_SEC_GADID,NULL };
struct Gadget SGadget50 = { &SGadget51,71,62,72,11,
NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder1a,NULL,
&SIText21,NULL,NULL,YES_GADID,NULL };
struct Gadget AboutGad = { NULL,198,95,72,11,NULL,
RELVERIFY,
BOOLGADGET+REQGADGET,
(APTR)&SBorder1a,NULL,
&SIText21,NULL,NULL,1,NULL };
SHORT ReqBorVeca[] = { 0,75,309,75,309,0 };
SHORT ReqBorVecb[] = { 0,75,0,0,309,0 };
SHORT cmpBorVeca[] = { 0,96,349,96,349,0 };
SHORT cmpBorVecb[] = { 0,96,0,0,349,0 };
SHORT asmBorVeca[] = { 0,139,271,139,271,0 };
SHORT asmBorVecb[] = { 0,139,0,0,271,0 };
SHORT VerBorVeca[] = { 0,139,271,139,271,0 };
SHORT VerBorVecb[] = { 0,139,0,0,271,0 };
SHORT TypeBorVeca[] = { 0,96,423,96,423,0 };
SHORT TypeBorVecb[] = { 0,96,0,0,423,0 };
SHORT AboutBorVeca[] = { 0,117,467,117,467,0 };
SHORT AboutBorVecb[] = { 0,117,0,0,467,0 };
SHORT JedecBorVeca[] = { 0,79,204,79,204,0 };
SHORT JedecBorVecb[] = { 0,79,0,0,204,0 };
struct Border ReqBorderb = { 0,0,2,0,JAM1,3,ReqBorVecb,NULL};
struct Border ReqBordera = { 0,0,1,0,JAM1,3,ReqBorVeca,&ReqBorderb};
struct Border cmpBorderb = { 0,0,2,0,JAM1,3,cmpBorVecb,NULL};
struct Border cmpBordera = { 0,0,1,0,JAM1,3,cmpBorVeca,&cmpBorderb};
struct Border asmBorderb = { 0,0,2,0,JAM1,3,asmBorVecb,NULL};
struct Border asmBordera = { 0,0,1,0,JAM1,3,asmBorVeca,&asmBorderb};
struct Border TypeBorderb = { 0,0,2,0,JAM1,3,TypeBorVecb,NULL};
struct Border TypeBordera = { 0,0,1,0,JAM1,3,TypeBorVeca,&TypeBorderb};
struct Border AboutBorderb = { 0,0,2,0,JAM1,3,AboutBorVecb,NULL};
struct Border AboutBordera = { 0,0,1,0,JAM1,3,AboutBorVeca,&AboutBorderb};
struct Border JedecBorderb = { 0,0,2,0,JAM1,3,JedecBorVecb,NULL};
struct Border JedecBordera = { 0,0,1,0,JAM1,3,JedecBorVeca,&JedecBorderb};
struct Requester req = { NULL,170,40,310,76,0,0,
&GadgetY,&ReqBordera,&ITextW,
NOISYREQ,3,NULL,NULL,NULL };
struct Requester cmpreq = { NULL,145,30,350,97,0,0,
&SGadget30,&cmpBordera,&SIText33,
NOISYREQ,3,NULL,NULL,NULL };
struct Requester asmreq = { NULL,184,20,272,140,0,0,
&SGadget1,&asmBordera,&SIText13,
NOISYREQ,3,NULL,NULL,NULL };
struct Requester VerReq = { NULL,184,20,272,140,0,0,
&SGadget40,&asmBordera,&SIText40,
NOISYREQ,3,NULL,NULL,NULL };
struct Requester TypeReq = { NULL,114,30,424,97,0,0,
&SGadget20,&TypeBordera,&SIText19,
NOISYREQ,3,NULL,NULL,NULL };
struct Requester AboutReq={ NULL,86,18,468,118,0,0,
&AboutGad,&AboutBordera,&AboutTxt1,
NOISYREQ,3,NULL,NULL,NULL };
struct Requester JedecReq={ NULL,217,30,205,80,0,0,
&SGadget50,&JedecBordera,&SITextJR,
NOISYREQ,3,NULL,NULL,NULL };
char filename[FCHARS+4]; /*Puffer für Filenamen*/
char directoryname[DSIZE]; /*Puffer für Directory*/
char path[DSIZE+FCHARS+4]; /*Puffer für Dir+File*/
/*+4 für Suffix*/
struct ReqFileRequester MyFileReqStruct = /*FileRequester aus req.lib*/
{
REQVERSION, NULL,
(char *)&directoryname,
(char *)&filename,
(char *)&path,
NULL,
0,12,32,10,
FRQCACHINGM|FRQINFOGADGETM|FRQABSOLUTEXYM,
1,2,2,0,0, /*Dir,File,Dev,Font,Fontsize*/
2,1, /*Detail,Block-Farben*/
2,2,2,2, /*GadTxt,Text,String,StrnGad*/
2,2, /*Border,Gadget-Farben*/
};
/* Schreibverhalten: Läßt Requester erscheinen, in dem eingestellt werden
kann ob ein Leertest und/oder Verify nach einem
schreibenden Zugriff auf ein GAL gemacht werden soll.
Aufruf : Schreibverhalten();
Parameter: ---
Ergebnis : ---
*/
void Schreibverhalten()
{
struct IntuiMessage *imsg;
ULONG class;
USHORT code,gadID;
if (Request(&VerReq,window)) {
for (;;) {
imsg = (struct IntuiMessage *) GetMsg(window->UserPort);
if (!imsg) WaitPort (window->UserPort);
else {
class = imsg->Class;
code = imsg->Code;
if (class==GADGETUP) gadID=((struct Gadget *)imsg->IAddress)->GadgetID;
ReplyMsg(imsg);
if (class == VANILLAKEY) {
if (code == 'w') {
EndRequest(&VerReq,window);
return;
}
}
if (class == GADGETUP) {
switch (gadID) {
case YES_GADID:
EndRequest(&VerReq,window);
return;
case 3:
Config.ProgEmptyTest = !Config.ProgEmptyTest;
break;
case 4:
Config.ProgVerify = !Config.ProgVerify;
break;
case 5:
Config.CopyEmptyTest = !Config.CopyEmptyTest;
break;
case 6:
Config.CopyVerify = !Config.CopyVerify;
break;
case 7:
Config.EraseEmptyTest = !Config.EraseEmptyTest;
break;
}
}
}
}
}
}
/* JedecRequster: Läßt Requester erscheinen, in dem eingestellt werden kann,
was wie im Jedec-File stehen soll.
Aufruf : JedecReq();
Parameter: ---
Ergebnis : ---
*/
void JedecRequester()
{
struct IntuiMessage *imsg;
ULONG class;
USHORT code,gadID;
if (Request(&JedecReq,window)) {
for (;;) {
imsg = (struct IntuiMessage *) GetMsg(window->UserPort);
if (!imsg) WaitPort (window->UserPort);
else {
class = imsg->Class;
code = imsg->Code;
if (class==GADGETUP) gadID=((struct Gadget *)imsg->IAddress)->GadgetID;
ReplyMsg(imsg);
if (class == VANILLAKEY) {
if (code == 'w') {
EndRequest(&JedecReq,window);
return;
}
}
if (class == GADGETUP) {
switch (gadID) {
case YES_GADID:
EndRequest(&JedecReq,window);
return;
case JED_SEC_GADID:
Config.JedecSecBit = !Config.JedecSecBit;
break;
case JED_FSCHK_GADID:
Config.JedecFuseChk = !Config.JedecFuseChk;
break;
case JED_FLCHK_GADID:
Config.JedecFileChk = !Config.JedecFileChk;
break;
}
}
}
}
}
}
/* About: zeigt About-Text
Aufruf : About();
Parameter: ---
Ergebnis : ---
*/
void About()
{
struct IntuiMessage *imsg;
ULONG class;
USHORT gadID;
if (Request(&AboutReq,window)) {
for (;;) {
imsg = (struct IntuiMessage *) GetMsg(window->UserPort);
if (!imsg) WaitPort (window->UserPort);
else {
class = imsg->Class;
if (class==GADGETUP) gadID=((struct Gadget *)imsg->IAddress)->GadgetID;
ReplyMsg(imsg);
if (class == VANILLAKEY) {
EndRequest(&AboutReq,window);
return;
}
if (class == GADGETUP) {
if (gadID == 1) {
EndRequest(&AboutReq,window);
return;
}
}
}
}
}
}
/* mystrcmp: wie strcmp, aber keine Unterscheidung zwischen Groß- und
Kleinschreibung
Aufruf: result = mystrcmp(cptr1, cptr2);
cptr1: Zeiger auf 1. String
cptr2: Zeiger auf 2. String
Ergebnis:
result = 1: nicht gleich
= 0: gleich
*/
int mystrcmp(cptr1, cptr2)
char *cptr1, *cptr2;
{
while (*cptr1 && *cptr2) {
if (_tolower(*cptr1) != _tolower(*cptr2))
return(1);
cptr1++;
cptr2++;
}
if (!*cptr1 && !*cptr2)
return(0);
else
return(1);
}
/* MyFileReq: öffnet den FileRequester aus der "req.library"
Aufruf: antwort = MyFileReq((char *)headtxt, (char *)showtxt, int showreq);
headtxt: Zeiger auf File-Requester-Titel
showtxt: Zeiger auf Suffix
showreq: YES: FileRequester zeigen; NO: keinen Requester
Ergebnis: 1 : O.K. wurde angeklickt
0 : Cancel wurde angeklickt
*/
int MyFileReq(headtxt,showtxt,showreq)
char *headtxt, *showtxt;
int showreq;
{
char *pos1, *pos2;
int freq = YES;
MyFileReqStruct.WindowLeftEdge = 124;
MyFileReqStruct.Title = headtxt; /*Überschrift*/
MyFileReqStruct.Show[0]='#'; /*Show-Text*/
MyFileReqStruct.Show[1]='?';
MyFileReqStruct.Show[2]=0;
strcat(&MyFileReqStruct.Show[0],showtxt);
/*falls vorhanden, Suffix löschen*/
if (strlen(&filename[0])>=4) { /*und "showtxt" anhängen */
pos1 = (char *)(&filename[0] + (long)strlen(&filename[0]) - (long)strlen(showtxt));
if ((!mystrcmp(pos1,(char *)".pld")) || (!mystrcmp(pos1,(char *)".jed")) ||
(!mystrcmp(pos1,(char *)".pin")) || (!mystrcmp(pos1,(char *)".chp")) ||
(!mystrcmp(pos1,(char *)".fus"))) {
*pos1 = 0;
strcat(&filename[0], showtxt);
}
}
if (showreq) /*FileRequester zeigen?*/
freq = FileRequester(&MyFileReqStruct);
if ((showreq && freq) || !showreq) {
if (strlen(&filename[0])>=4) { /*Suffix anhängen*/
pos1 = (char *)(&filename[0]+(long)strlen(&filename[0])-(long)strlen(showtxt));
if (mystrcmp(pos1,showtxt)) { /*Suffix nur anhängen, wenn*/
strcat(&filename[0], showtxt); /*es nicht schon da steht */
strcat(&path[0], showtxt);
}
}
else {
if (!strlen(&filename[0])) /*kein File angegeben?*/
return(0); /*dann Abbruch*/
strcat(&filename[0], showtxt);
strcat(&path[0], showtxt);
}
/*Wenn kein Requester gezeigt */
/*wurde (showreq = NO), muß */
if (!showreq) { /*der Pfad "von Hand" zusammen-*/
strcpy(&path[0],&directoryname[0]); /*gestellt werden.*/
pos1 = (char *)(&directoryname[0]+((long)strlen(&directoryname[0])-1L));
pos2 = (char *)(&path[0]+((long)strlen(&path[0])));
if (!((*pos1 == ':') || (*pos1 == '/') || !*pos1)) {
*pos2++ = '/';
*pos2 = 0x00; /*Stringende*/
}
strcat(&path[0],&filename[0]);
}
return(1);
}
else
return(0);
}
/* CompareRequester: öffnet den Requester für die Art des Vergleichs
Parameter: keine
Ergebnis : 0 : Abbruch
1 : GAL - GAL
2 : GAL - Jedec
3 : Jedec - GAL
*/
int CompareRequester()
{
struct IntuiMessage *imsg;
ULONG class;
USHORT code,gadID;
if (Request(&cmpreq,window)) {
for (;;) {
imsg = (struct IntuiMessage *) GetMsg(window->UserPort);
if (!imsg) WaitPort (window->UserPort);
else {
class = imsg->Class;
code = imsg->Code;
if (class==GADGETUP) gadID=((struct Gadget *)imsg->IAddress)->GadgetID;
ReplyMsg(imsg);
if (class == VANILLAKEY) {
switch(code) {
case '1':
EndRequest(&cmpreq,window);
return(1);
case '2':
EndRequest(&cmpreq,window);
return(2);
case '3':
EndRequest(&cmpreq,window);
return(3);
case 0x1B:
case 'a' :
EndRequest(&cmpreq,window);
return(0);
}
}
if (class == GADGETUP) {
switch (gadID) {
case NO_GADID: {
EndRequest(&cmpreq,window);
return(0);
}
case GALGAL_GADID: {
EndRequest(&cmpreq,window);
return(1);
}
case GALJEDEC_GADID: {
EndRequest(&cmpreq,window);
return(2);
}
case JEDECGAL_GADID: {
EndRequest(&cmpreq,window);
return(3);
}
}
}
}
}
}
else
return(0);
}
/* MyRequest:
öffnet einen Requester und wartet auf die Antwort
Aufruf: antwort = MyRequest(mode,text);
mode: CONT_REQ : Requester mit Weiter/Abbruch-Gadgets
ERR_REQ : Requester für Fehlermeldungen (Abbruch/Abbruch)
INFO_REQ : Requester für Informationen (Weiter/Weiter)
ATYPE_REQ: Requester für A-Typ oder nicht
GALTYPE_REQ: Öffnet Requester in dem der GAL-Typ eingestellt
werden kann, falls im Menü "Typ-Requester" eingestellt ist.
Wenn dies nicht der Fall ist, dann wird ein normaler
Frage-Requester ("CONT_REQ") ausgegeben.
text: Zeiger auf Requester-Text
antwort: 0=Abbruch oder Fehler, 1=Bestätigung
bei GALTYPE_REQ: 1 = GAL16V8
2 = GAL16V8A
3 = GAL20V8
4 = GAL20V8A
*/
int MyRequest(mode,text)
int mode;
UBYTE *text;
{
struct IntuiMessage *imsg;
struct Requester *myreq;
ULONG class;
USHORT code,gadID;
int width;
ITextW.NextText = NULL; /*für AType-Req.*/
if (mode == GALTYPE_REQ) { /* wenn autom. A-Typ, dann*/
if (Config.AutoAType) { /* die A-Typ-Gadgets de-*/
SGadget23.Flags = SGadget23.Flags | GADGDISABLED; /*aktivieren, sonst*/
SGadget21.Flags = SGadget21.Flags | GADGDISABLED; /*aktivieren*/
}
else {
SGadget23.Flags = SGadget23.Flags & ~GADGDISABLED;
SGadget21.Flags = SGadget21.Flags & ~GADGDISABLED;
}
}
if (Config.GALTypeReq && (mode == GALTYPE_REQ)) {
myreq = &TypeReq;
SIText20.LeftEdge=(SHORT)(212-strlen(text)*8/2);
SIText20.IText = text;
}
else {
if (mode == ERASE_REQ) {
ITextY.IText = (UBYTE *)" Erase ";
ITextN.IText = (UBYTE *)"Cancel ";
}
if (mode == ATYPE_REQ) {
ITextY.IText = (UBYTE *)"A-Type";
ITextN.IText = (UBYTE *)"normal";
ITextW.NextText = &ATypeTxt;
}
if (mode == ERR_REQ) {
ITextY.IText = (UBYTE *)"Cancel ";
ITextN.IText = (UBYTE *)"Cancel";
}
if ((mode == CONT_REQ) || (mode == GALTYPE_REQ)) {
ITextY.IText = (UBYTE *)" Cont";
ITextN.IText = (UBYTE *)"Cancel ";
}
if (mode == INFO_REQ) {
ITextY.IText = (UBYTE *)" Cont";
ITextN.IText = (UBYTE *)" Cont";
}
if (strlen(text) < 39)
width = 310;
else
width = (int)(strlen(text))*8+10;
ITextW.LeftEdge = (SHORT)(width/2-strlen(text)*8/2);
ITextW.IText = text;
req.LeftEdge = 320-width/2;
req.Width = width;
GadgetN.LeftEdge = width-104;
ReqBorVeca[2] = ReqBorVeca[4] = ReqBorVecb[4] = width-1;
myreq = &req;
}
if (Request(myreq,window)) {
for (;;) {
imsg = (struct IntuiMessage *) GetMsg(window->UserPort);
if (!imsg) WaitPort (window->UserPort);
else {
class = imsg->Class;
code = imsg->Code;
if (class==GADGETUP) gadID=((struct Gadget *)imsg->IAddress)->GadgetID;
ReplyMsg(imsg);
if (class == VANILLAKEY) {
if (Config.GALTypeReq && (mode == GALTYPE_REQ)) {
switch (code) {
case '1':
EndRequest(myreq,window);
SetGALType (GAL16V8,NO);
return(1);
case '2':
if (!Config.AutoAType) {
EndRequest(myreq,window);
SetGALType (GAL16V8,YES);
return(2);
}
break;
case '3':
EndRequest(myreq,window);
SetGALType (GAL20V8,NO);
return(3);
case '4':
if (!Config.AutoAType) {
EndRequest(myreq,window);
SetGALType (GAL20V8,YES);
return(4);
}
break;
}
}
else
if (code == 'w') { /*weiter ?*/
EndRequest(myreq,window);
return(1);
} /*ESC oder Abbruch?*/
if ((code == 0x1B) || (code == 'a')) {
EndRequest(myreq,window);
return(0);
}
}
if (class == GADGETUP) {
switch (gadID) {
case YES_GADID:
EndRequest(myreq,window);
return(1);
case NO_GADID:
EndRequest(myreq,window);
return(0);
case 3:
EndRequest(myreq,window);
SetGALType (GAL16V8,NO);
return(1);
case 4:
EndRequest(myreq,window);
SetGALType (GAL16V8,YES);
return(2);
case 5:
EndRequest(myreq,window);
SetGALType (GAL20V8,NO);
return(3);
case 6:
EndRequest(myreq,window);
SetGALType (GAL20V8,YES);
return(4);
}
}
}
}
}
else
return(0);
}
/* AsmRequester: öffnet den Requester mit den Assembler-Optionen
Parameter: keine
Ergebnis : 0 : Abbruch
1 : Weiter
*/
int AsmRequester()
{
struct IntuiMessage *imsg;
ULONG class;
USHORT code,gadID;
if (Request(&asmreq,window)) {
for (;;) {
imsg = (struct IntuiMessage *) GetMsg(window->UserPort);
if (!imsg) WaitPort (window->UserPort);
else {
class = imsg->Class;
code = imsg->Code;
if (class==GADGETUP) gadID=((struct Gadget *)imsg->IAddress)->GadgetID;
ReplyMsg(imsg);
if (class == VANILLAKEY) {
if (code == 'w') { /*Weiter ?*/
EndRequest(&asmreq,window);
return(1);
} /*ESC oder Abbruch?*/
if ((code == 0x1B) || (code == 'a')) {
EndRequest(&asmreq,window);
return(0);
}
}
if (class == GADGETUP) {
switch (gadID) {
case WEITER_GADID:
EndRequest(&asmreq,window);
return(1);
break;
case ABBRUCH_GADID:
EndRequest(&asmreq,window);
return(0);
break;
case JEDEC_GADID:
Config.GenJedec = !Config.GenJedec;
break;
case FUSE_GADID:
Config.GenFuse = !Config.GenFuse;
break;
case CHIP_GADID:
Config.GenChip = !Config.GenChip;
break;
case PIN_GADID:
Config.GenPin = !Config.GenPin;
break;
case AUTOSAVE_GADID:
Config.AutoSave = !Config.AutoSave;
break;
case AUTOGAL_GADID:
Config.AutoGAL = !Config.AutoGAL;
break;
}
}
}
}
}
else
return(0);
}
/* FileSize:
gibt die Länge einer Datei zurück
Aufruf: size=FileSize(filename);
filename: Zeiger auf Filenamen
Ergebnis: -1 : File existiert nicht
-2 : kein Speicher für FileInfoBlock
size: Filelänge
*/
long FileSize(filename)
UBYTE *filename;
{
struct FileInfoBlock *fib;
struct FileLock *lock;
LONG filesize;
if((lock=(struct FileLock *) Lock(filename,ACCESS_READ))) {
fib=(struct FileInfoBlock *)AllocMem((long)sizeof(struct FileInfoBlock),MEMF_CHIP);
if (fib!=NULL) {
if (Examine(lock,fib))
filesize=fib->fib_Size;
else filesize=-1L;
UnLock(lock);
FreeMem(fib,(long)sizeof(struct FileInfoBlock));
return(filesize);
}
else
return(-2L); /*Mem-Error*/
}
else
return(-1L); /*File existiert nicht*/
}
/* ReadFile
File einlesen
Aufruf: error=ReadFile(filename,filesize,filebuff)
filename: Zeiger auf Filenamen
filesize: Größe der Datei in Bytes
filebuff: Adresse, an die die Datei gelesen werden soll
Ergebnis: error: 1=kein Fehler, 0=Fehler
*/
int ReadFile(filename,filesize,filebuff)
UBYTE *filename,*filebuff;
LONG filesize;
{
long actlength;
struct FileHandle *fh;
if ((fh=Open(filename,MODE_OLDFILE))) {
actlength=Read(fh,filebuff,filesize);
Close(fh);
if (actlength==-1L) return(0);
else return(1);
}
else
return(0);
}
/*ErrorReq
gibt zu einer Fehlernummer den entsprechenden Requester aus
Aufruf: ErrorReq(errornum);
errornum: Fehlernummer
*/
void ErrorReq(errornum)
int errornum;
{
switch (errornum) {
case 1: MyRequest(ERR_REQ,(UBYTE*)"Can't find file!");
break;
case 2: MyRequest(ERR_REQ,(UBYTE*)"Not enough free memory!");
break;
case 3: MyRequest(ERR_REQ,(UBYTE*)"Can't load file!");
break;
case 4: MyRequest(ERR_REQ,(UBYTE*)"File is empty!");
break;
case 5: MyRequest(ERR_REQ,(UBYTE*)"Error in JEDEC file!");
break;
case 6: MyRequest(ERR_REQ,(UBYTE*)"GAL is not empty!");
break;
case 7: MyRequest(ERR_REQ,(UBYTE*)"No pinnames found.");
break;
case 8: MyRequest(ERR_REQ,(UBYTE*)"Can't close file!");
break;
case 9: MyRequest(ERR_REQ,(UBYTE*)"Bad type of GAL selected!");
break;
case 10: MyRequest(ERR_REQ,(UBYTE*)"Can't load 's:GALer.config'!");
break;
case 11: MyRequest(ERR_REQ,(UBYTE*)"Can't save 's:GALer.config'!");
break;
case 12: MyRequest(ERR_REQ,(UBYTE*)"Can't open window!");
break;
case 13: MyRequest(ERR_REQ,(UBYTE*)"Can't save file!");
break;
}
}
/* PrintText
gibt Text im Text-Feld aus
Aufruf: PrintText(text);
text : Zeiger auf Text
newline: 1: ypos auf nächste Zeile
0: ypos nicht auf nächste Zeile
Aufruf mit newline = 0 eigentlich nur sinnvoll wenn
zuvor schon mal mit newline = 1 aufgerufen wurde
Anwendungsbeispiel:
PrintText("führe Verify durch...",1);
Nach erfolgreichem Verify: PrintText(" O.K.",0);
=> "führe Verify durch... O.K."
*/
void PrintText(text, newline)
UBYTE *text;
int newline;
{
static long delta_x;
if (newline)
if (ytxt<190)
ytxt+=10;
else
ScrollRaster(rp,0L,10L,31L,162L,609L,194L);
if (newline)
Move(rp,40L,(long)ytxt);
else
Move(rp,40L+delta_x,(long)ytxt);
Text(rp,text,(long)strlen(text));
delta_x = (long)strlen(text)*8L;
}
/*gibt "Fehler in Zeile xyz" aus
Aufruf: PrintErrorLine(line);
line: Zeilennummer
*/
void PrintErrorLine(line)
int line;
{
sprintf(&ErrorLineStr[16],"%4d:",line);
PrintText(&ErrorLineStr[0],1);
}
/* Voreinstellungen laden ("s:GALer.config") und Menüs, Gadgets, usw.
entsprechend einstellen
*/
void LoadConfig()
{
long filelength;
struct FileHandle *fh;
if ((fh = Open((UBYTE *)"s:GALer.config",MODE_OLDFILE))) {
filelength = Read(fh,&DummyConfig,(long)sizeof(struct Configuration));
Close(fh);
if (filelength == -1L)
ErrorReq(10);
else /* kein Fehler beim Lesen?*/
Config = DummyConfig; /* dann Config übernehmen*/
}
GALType = Config.GALType; /*GAL-Typ einstellen*/
if (GALType == GAL16V8) {
GALType = GAL16V8;
MaxFuseAdr = MAX_FUSE_ADR16;
SigAdr = SIG_ADR16;
SetGAL (GAL16V8);
DrawGAL (GAL16V8);
strncpy (&title[59], (char *)"GAL16V8", 7);
MenuItem13.Flags |= CHECKED; /*GAL16V8-Menü*/
}
else {
GALType = GAL20V8;
MaxFuseAdr = MAX_FUSE_ADR20;
SigAdr = SIG_ADR20;
SetGAL (GAL20V8);
DrawGAL (GAL20V8);
strncpy (&title[59], (char *)"GAL20V8", 7);
MenuItem13b.Flags |= CHECKED; /*GAL20V8-Menü*/
}
if (Config.AType)
title[67] = 'A';
else
title[67] = ' ';
SetWindowTitles(window,-1L,(UBYTE*)title);
if (Config.AType)
MenuItem14b.Flags |= CHECKED; /*A-Typ-Menü*/
if (Config.AutoAType) { /*Auto-A-Typ*/
MenuItem14b.Flags = MenuItem14b.Flags & ~ITEMENABLED; /*A-Typ-Menü*/
MenuItem14a.Flags |= CHECKED; /*Auto A-Typ-Menü*/
}
if (Config.GALTypeReq)
MenuItem14.Flags |= CHECKED; /*Typ-Requester-Menü*/
if (Config.GenJedec)
SGadget1.Flags |= SELECTED;
if (Config.GenFuse)
SGadget2.Flags |= SELECTED;
if (Config.GenChip)
SGadget3.Flags |= SELECTED;
if (Config.GenPin)
SGadget4.Flags |= SELECTED;
if (Config.AutoSave)
SGadget5.Flags |= SELECTED;
if (Config.AutoGAL)
SGadget9.Flags |= SELECTED;
if (Config.JedecSecBit)
SGadget51.Flags |= SELECTED;
if (Config.JedecFuseChk)
SGadget52.Flags |= SELECTED;
if (Config.JedecFileChk)
SGadget53.Flags |= SELECTED;
if (Config.ProgEmptyTest)
SGadget42.Flags |= SELECTED;
if (Config.ProgVerify)
SGadget43.Flags |= SELECTED;
if (Config.CopyEmptyTest)
SGadget44.Flags |= SELECTED;
if (Config.CopyVerify)
SGadget45.Flags |= SELECTED;
if (Config.EraseEmptyTest)
SGadget46.Flags |= SELECTED;
}
/* Voreinstellungen sichern - File "s:GALer.config"*/
void SaveConfig()
{
long filelength;
struct FileHandle *fh;
Config.GALType = GALType;
if ((fh = Open((UBYTE *)"s:GALer.config",MODE_NEWFILE))) {
filelength = Write(fh,&Config,(long)sizeof(struct Configuration));
Close(fh);
if (filelength == -1L)
ErrorReq(11);
}
else
ErrorReq(11);
}
/* SetGALType: alle Variablen usw. auf den gewünschten GAL-Typ einstellen
Aufruf: SetGALType(galtype, atype);
Parameter: galtype = GAL16V8 oder GAL20V8
atype = YES : GAL vom Typ A
NO : "normales" GAL
*/
void SetGALType(galtype, atype)
int galtype, atype;
{
if ((galtype == GAL16V8) && (GALType != GAL16V8)) {
GALType = GAL16V8;
MaxFuseAdr = MAX_FUSE_ADR16;
SigAdr = SIG_ADR16;
SetGAL (GAL16V8);
DrawGAL (GAL16V8);
strncpy (&title[59], (char *)"GAL16V8", 7);
MenuItem13.Flags |= CHECKED; /*GAL16V8-Menü*/
MenuItem13b.Flags &= (~CHECKED); /*GAL20V8-Menü*/
}
if ((galtype == GAL20V8) && (GALType != GAL20V8)) {
GALType = GAL20V8;
MaxFuseAdr = MAX_FUSE_ADR20;
SigAdr = SIG_ADR20;
SetGAL (GAL20V8);
DrawGAL (GAL20V8);
strncpy (&title[59], (char *)"GAL20V8", 7);
MenuItem13.Flags &= (~CHECKED); /*GAL20V8-Menü*/
MenuItem13b.Flags |= CHECKED; /*GAL20V8-Menü*/
}
if (!Config.AutoAType) { /*A-Typ nur ändern, wenn keine*/
Config.AType = atype; /*autom. A-Typ-Einstellung*/
if (Config.AType) {
title[67] = 'A';
MenuItem14b.Flags |= CHECKED; /*A-Typ-Menü*/
}
else {
title[67] = ' ';
MenuItem14b.Flags &= (~CHECKED); /*A-Typ-Menü*/
}
}
SetWindowTitles(window,-1L,(UBYTE*)title);
}
/* Die Routienen "AddByte", "AddString", "IncPointer", "DecPointer" und
"FreeBuffer" erleichtern die Erstellung und Bearbeitung von verketteten
Speicherlisten.
*/
/*AddByte: Schreibt das Byte "code" in den Puffer. Wenn das Ende des
Puffers erreicht ist, wird ein neuer erstellt
(Struktur Buffer).
Aufruf : result = AddByte(buff,code);
Einsprung: code: Byte das in den Puffer an die Position "buff"
geschrieben werden soll, "buff" wird anschließend um eins erhöht
buff: Zeiger auf ActBuffer-Struktur
Ergebnis: Returnwert = 0: alles o.k. sonst: Fehler (kein Speicher)
buff enthält neuen Entry-Zeiger und den entsprechenden Puffer-
Anfang und das Ende
*/
int AddByte(buff,code)
struct ActBuffer *buff;
UBYTE code;
{
struct Buffer *mybuff;
if ((buff->Entry) < (buff->BuffEnd)) { /*noch im Puffer?*/
*buff->Entry++ = code; /*ja, dann Byte eintragen*/
}
else { /*nein, dann neuen Puffer erstellen*/
if (!(mybuff = (struct Buffer *)AllocMem((long)sizeof(struct Buffer),MEMF_PUBLIC|MEMF_CLEAR))) {
ErrorReq(2); /*kein Speicher mehr->Fehlermeldung*/
return(-1);
}
buff->ThisBuff->Next = mybuff; /*neuer Puffer ist aktueller*/
mybuff->Prev = buff->ThisBuff; /*vorheriger Puffer ist alter*/
buff->ThisBuff = mybuff; /*aktueller Puffer ist neuer*/
buff->Entry = (UBYTE *)(&mybuff->Entries[0]);
buff->BuffEnd = (UBYTE *)mybuff + (long)sizeof(struct Buffer);
*buff->Entry++ = code;
}
return(0);
}
/*AddString: Schreibt den String "strnptr" in den Puffer. Wenn das Ende des
Puffers erreicht ist, wird ein neuer erstellt.
(Struktur Buffer).
Aufruf : result = AddString(buff,strnptr);
Einsprung: strnptr: Zeiger auf String der in den Puffer an die Position
"buff" geschrieben werden soll, "buff" zeigt zum Schluß auf
das lezte Zeichen im String + 1.
buff: Zeiger auf ActBuffer-Struktur
Ergebnis: Returnwert = 0: alles o.k. sonst: Fehler (kein Speicher)
buff enthält neuen Entry-Zeiger und den entsprechenden Puffer-
Anfang und das Ende
*/
int AddString(buff, strnptr)
struct ActBuffer *buff;
UBYTE *strnptr;
{
while (*strnptr) {
if (AddByte(buff,*strnptr++))
return(-1);
}
}
/*IncPointer: Zeiger auf nächsten Eintrag im verketten Puffer
Aufruf: IncPointer(buff);
Parameter: buff : Zeiger auf ActBuffer-Struktur
Ergebnis : buff->Entry : zeigt auf nächstes Zeichen im Puffer
buff->BuffEnd : zeigt auf das Ende des Puffers, in den
Entry zeigt
buff->ThisBuff: zeigt auf Puffer-Anfang
ACHTUNG: es erfolgt keine Abfrage, ob das Ende des gesamten Puffers
schon erreicht ist
*/
void IncPointer(buff)
struct ActBuffer *buff;
{
buff->Entry++;
if (buff->Entry == buff->BuffEnd) { /*Pufferende erreicht?*/
buff->ThisBuff = buff->ThisBuff->Next; /*ja, dann auf nächsten Puffer*/
buff->Entry = (UBYTE *)(&buff->ThisBuff->Entries[0]);
buff->BuffEnd = (UBYTE *)buff->ThisBuff + (long)sizeof(struct Buffer);
}
}
/*DecPointer: Zeiger auf vorigen Eintrag im verketten Puffer
Aufruf: IncPointer(buff);
Parameter: buff : Zeiger auf ActBuffer-Struktur
Ergebnis : buff->Entry : zeigt auf voriges Zeichen im Puffer
buff->BuffEnd : zeigt auf das Ende des Puffers, in den
Entry zeigt
buff->ThisBuff : zeigt auf Puffer-Anfang
ACHTUNG: es erfolgt keine Abfrage, ob der Anfang des gesamten Puffers
schon erreicht ist
*/
void DecPointer(buff)
struct ActBuffer *buff;
{
buff->Entry--;
if (buff->Entry < &buff->ThisBuff->Entries[0]) { /*Pufferanfang erreicht?*/
buff->ThisBuff = buff->ThisBuff->Prev; /*dann auf vorigen Puffer*/
buff->BuffEnd = (UBYTE *)buff->ThisBuff + (long)sizeof(struct Buffer);
buff->Entry = (UBYTE *)((buff->BuffEnd)-1L);
}
}
/*FreeBuffer: gibt die verketteten Puffer wieder frei
Aufruf: FreeBuffer(buff);
Einsprung: buff: Zeiger auf ersten Speicherblock
Ergebnis : ---
*/
void FreeBuffer(buff)
struct Buffer *buff;
{
struct Buffer *nextbuff;
do {
nextbuff = buff->Next;
FreeMem(buff,(long)sizeof(struct Buffer)); }
while (buff = nextbuff);
}